import axios from 'axios';

const AMAP_KEY = 'e924a4f20bcb4cf72015d066ab5b1c5e'; // 你的高德key

const amapAxios = axios.create({
  baseURL: 'https://restapi.amap.com/v3',
  timeout: 10000,
});

// 逆地理编码
export async function getRegeo({ longitude, latitude }: { longitude: number; latitude: number }) {
  const res = await amapAxios.get('/geocode/regeo', {
    params: {
      key: AMAP_KEY,
      location: `${longitude},${latitude}`,
      extensions: 'base',
    },
  });
  return res.data;
}

// 静态地图
export function getStaticMapUrl(longitude: number, latitude: number) {
  return `https://restapi.amap.com/v3/staticmap?location=${longitude},${latitude}&zoom=17&size=260*120&markers=mid,,A:${longitude},${latitude}&key=${AMAP_KEY}`;
} 